#ifndef __PACKET_H__
#define __PACKET_H__

#include <stdint.h>

/************************ TYPE DEFINTION *******************************/

typedef int16_t PACKET_TYPE;

/*********************** PACKET DEFINTION ******************************/

#define PACKET_INIT				1
#define PACKET_START			2
#define PACKET_STOP				3
#define PACKET_COMMAND_NOT_OK	4
#define PACKET_ASK_COMMAND 		5
#define PACKET_COMMAND_OK 		6
#define PACKET_STATUS		 	7
#define PACKET_ERROR 			8

#define PACKET_MAX_LENGTH sizeof(INIT_PACKET)

/* Packet header structure */
typedef struct
{
	PACKET_TYPE id_packet;
	
} PACKET_HDR;


/* Intialization packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	int16_t id_lot;
	int16_t part_type;
	int16_t nb_part_box;
	int16_t nb_box_palette;
	int16_t nb_palette_number;
	int16_t nb_defect_part;
	
} INIT_PACKET;


/* Start packet structure */
typedef struct
{
	PACKET_HDR hdr;

	/* Nothing */
	
} START_PACKET;



/* Stop packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	/* Nothing */
	
} STOP_PACKET;


/* Shutdown packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	/* Nothing */
	
} COMMAND_NOT_OK_PACKET;


/* Ask command packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	int16_t id_command;
	int16_t type_part;
	int16_t	num_palett;
} ASK_COMMAND_PACKET;


/* Command Done packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	int16_t id_command;
	
} COMMAND_OK_PACKET;


/* Status packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	int16_t num_lot;
	int32_t time;
	int16_t num_box;
	int16_t nb_defect_piece;
	
} STATUS_PACKET;



/* Error packet structure */
typedef struct
{
	PACKET_HDR hdr;
	
	int16_t	id_error;
	int16_t	parameter;
	
} ERROR_PACKET;

#endif